package com.situ.firmadmin.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.firmadmin.mapper.NoticeMapper;
import com.situ.firmadmin.pojo.Auth;
import com.situ.firmadmin.pojo.Notice;
import com.situ.firmadmin.pojo.User;
import com.situ.firmadmin.pojo.query.NoticeQuery;
import com.situ.firmadmin.pojo.vo.TypeCountVO;
import com.situ.firmadmin.service.INoticeService;
import com.situ.firmadmin.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Sun
 * @since 2024-09-27
 */
@Service
public class NoticeServiceImpl implements INoticeService {
	@Autowired
	private NoticeMapper noticeMapper;
	
	@Override
	public PageResult selectByPage(NoticeQuery noticeQuery, User user) {
		List<Notice> list=noticeMapper.selectByPage(noticeQuery,user);
		PageHelper.startPage(noticeQuery.getPage(), noticeQuery.getLimit());
		PageInfo<Notice> pageInfo=new PageInfo<>(list);
		int total=(int)pageInfo.getTotal();
		return new PageResult(0,"",total,list);
	}
	
	@Override
	public void insert(Notice notice) {
		noticeMapper.insert(notice);
	}
	
	@Override
	public Notice selectById(Integer id) {
		return noticeMapper.selectById(id);
	}
	
	@Override
	public void update(Notice notice) {
		noticeMapper.update(notice);
	}
	
	@Override
	public void deleteById(Integer id) {
		noticeMapper.deleteById(id);
	}
	
	@Override
	public void deleteAll(Integer[] ids) {
		noticeMapper.deleteAll(ids);
	}
	
	@Override
	public List<Notice> selectByUserName(User user) {
		return noticeMapper.selectByUserName(user);
	}
	
	@Override
	public Integer informTotal(User user) {
		return noticeMapper.informTotal(user);
	}
	
	@Override
	public void receive(Integer id, User user) {
		noticeMapper.receive(id,user);
	}
	
	@Override
	public Long selectCount() {
		return noticeMapper.selectCount();
	}
	
	@Override
	public List<TypeCountVO> selectNoticeCount() {
		return noticeMapper.selectNoticeCount();
	}
}
